home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / window.zip / WINDOW.PAS < prev   
Pascal/Delphi Source File  |  1984-06-12  |  5KB  |  141 lines

  1. {TURBO Pascal:
  2.  
  3.      Window BIOS demonstration.  Written 1984 by J. Eric Roskos.
  4.  
  5.      This program demonstrates the Window BIOS, illustrating the recommended
  6.      methods of creating and deleting windows.  The following are the Window
  7.      BIOS functions; they are extensions to the ROM BIOS's INT 10H functions.
  8.  
  9.      AH=$41  Create Window.  (CH,CL) contains the (row,column) of the upper
  10.              left corner of the window, and (DH,DL) contains the (row,column)
  11.              of the lower right corner.  AX returns 0 if the window was
  12.              created, or 1 if there was no space in the BIOS tables to do so.
  13.  
  14.      AH=$42  Delete Window.  The top (most recently created) window is de-
  15.              leted.  Note that this uses the simple model of
  16.              overlayed sheets of paper on a desktop; the most recent window
  17.              is thus always the top sheet of paper on the desk.  This call
  18.              has no parameters. AX returns 0 if the window was deleted, or
  19.              1 if there was no window to delete.
  20.  
  21.      AH=$43  Create Frame.  A frame is drawn around the outermost rows and
  22.              columns of the current window.  Several nested frames may be
  23.              drawn, if any use for this exists.  This call presently has no
  24.              parameters, but AL must be 0.  No status is returned via AX.
  25.  
  26.      AH=$40  Change Window Dimensions.  This call should be used with
  27.              caution, as explained below.  The parameters to this call are
  28.              the same as for function $41.  The current window's dimensions
  29.              are changed to the specified values.  The new values should
  30.              place the new boundaries of the window inside the window most
  31.              recently created with call $41.  The purpose of this function is
  32.              to put non-scrolling information around the outside boundary
  33.              of the window, such as the "title bar" in Lisa/McIntosh
  34.              windows which appears at the top of some windows.  If this
  35.              function is used to change the dimensions, it must be used
  36.              again to set the window dimensions back to those originally
  37.              specified by function $41 before executing the Delete Window
  38.              function, or garbage will appear on the screen when the window
  39.              is deleted. No status is returned via AX.
  40. }
  41.  
  42. program windowdemo;
  43. type
  44.      recpack = record
  45.           ax,bx,cx,dx,bp,si,di,ds,es,flag: integer;
  46.      end;
  47.  
  48. var
  49.      param: recpack;
  50.      reply: string[80];
  51.  
  52. {
  53.      newwindow(l,t,r,b): create a new window.  The upper left corner is
  54.      at coordinates (l,t) and the bottom right corner is at coordinates
  55.      (r,b).  (l=left, t=top, r=right, b=bottom).  The coordinates have
  56.      origin (0,0) at the upper left corner of the screen.  Returns true if
  57.      the window could be created, or false if it couldn't (because there
  58.      wasn't any space left in the window stack).
  59. }
  60.  
  61. function newwindow(l,t,r,b: integer):boolean;
  62. begin
  63.      param.ax := $4100; { function $41 = create window }
  64.      param.cx := t*$100 + l;
  65.      param.dx := b*$100 + r;
  66.      intr($10,param);
  67.      newwindow := param.ax = 0;
  68.      param.ax := $4300; { function $43 = draw frame }
  69.      intr($10,param);
  70.      ClrScr; { screen MUST be cleared after creating window }
  71. end;
  72.  
  73. {
  74.      delwindow: delete the top window.  Returns true if the window was
  75.      deleted, or false if there was no window.  WARNING: if you use function
  76.      $40 to change the dimensions of the window, you MUST change them back
  77.      to their original value before deleting the window.
  78. }
  79.  
  80. function delwindow:boolean;
  81. begin
  82.      param.ax := $4200;
  83.      param.ds := Dseg;
  84.      intr($10,param);
  85.      delwindow := param.ax = 0;
  86. end;
  87.  
  88. {
  89.      xwindow: exit from all windows.  Calls delwindow repeatedly until all
  90.      the windows have been deleted.  It is a good idea to do this before
  91.      exiting from the program; although DOS will use whatever window you
  92.      create, some programs, such as the Turbo Pascal editor and Edix, will
  93.      not work right in smaller windows.
  94. }
  95.  
  96. procedure xwindow;
  97. begin
  98.        repeat until not delwindow;
  99. end;
  100.  
  101.  
  102. begin
  103.      if not newwindow(5,5,50,17) then writeln('New window failed.');
  104.      writeln('Hello, I am in a window.');
  105.      delay(1000);
  106.      writeln('As soon as I fill this one up just a little bit here to make sure everything');
  107.      delay(1000);
  108.      writeln('is fine, I will switch');
  109.      delay(1000);
  110.      writeln('to another window.');
  111.      delay(1000);
  112.      if not newwindow(10,3,20,8) then writeln('New window failed.');
  113.      delay(1000);
  114.      writeln('There now, is');
  115.      delay(1000);
  116.      writeln('this narrow');
  117.      delay(1000);
  118.      writeln('enough for you,');
  119.      delay(1000);
  120.      writeln('or not?  lets');
  121.      delay(1000);
  122.      writeln('have some scr-');
  123.      delay(1000);
  124.      writeln('olling here.');
  125.      delay(1000);
  126.      writeln('That was a');
  127.      delay(1000);
  128.      writeln('hyphenated word,');
  129.      delay(1000);
  130.      writeln('not an error');
  131.      delay(1000);
  132.      write('[cr]:');
  133.      readln(reply);
  134.      if not delwindow then writeln('window deletion failed');
  135.      write('Now we''re back here!  Push [cr] again.');
  136.      readln(reply);
  137.      if not delwindow then writeln('window deletion failed');
  138.      writeln('Now everything should be back to normal.');
  139.      xwindow;
  140. end.
  141.